﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

public partial class fare_details : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) return;
        try
        {
            DataSet dsFare=new DataSet();
            int ret_code;
            string ret_msg;
            //string pwd_sha1 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Application["PWD"].ToString(), "SHA1");
            string sign;
            string inbuf = Request.QueryString["AIRLINE"] + "|" + Request.QueryString["FARE_CODE"] + "|" + Application["HASH_PWD"].ToString();
            sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(inbuf, "MD5");
            CRSI.Query instFlt = new CRSI.Query();
            dsFare = instFlt.QueryFareDetail(Request.QueryString["AIRLINE"], Request.QueryString["FARE_CODE"], Request.QueryString["ORI"], Request.QueryString["DES"],Request.QueryString["TAX_TYPE"], Convert.ToInt16(Request.QueryString["DBF"]),
                Convert.ToInt16(Request.QueryString["LANG"]), Application["UID"].ToString(), sign, out ret_code, out ret_msg);
            if (ret_code != 0)
            {
                lblRules.Text = ret_msg+"/"+ret_code.ToString();
            }
            else if (dsFare.Tables[0].Rows.Count == 1)
            {
                lblFareName.Text = dsFare.Tables[0].Rows[0]["fare_name"].ToString();
                lblFareCode.Text = dsFare.Tables[0].Rows[0]["code"].ToString();
                lblLine.Text = dsFare.Tables[0].Rows[0]["trip_line"].ToString();
                lblSeatMin.Text = dsFare.Tables[0].Rows[0]["seats_min"].ToString();
                lblStayMin.Text = dsFare.Tables[0].Rows[0]["stay_min"].ToString();
                lblStayMax.Text = dsFare.Tables[0].Rows[0]["stay_max"].ToString();
                //lblChgNameFee.Text = dsFare.Tables[0].Rows[0]["chg_name_fee"].ToString();
                //lblChgNameBefore.Text = dsFare.Tables[0].Rows[0]["chg_name_before"].ToString();
                //lblChgFltFee.Text = dsFare.Tables[0].Rows[0]["chg_flt_fee"].ToString();
                //lblChgFltBefore.Text = dsFare.Tables[0].Rows[0]["chg_flt_before"].ToString();

                lblPrice.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["adt_price"].ToString();
                lblAirportTax.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["adt_taxes"].ToString();
                lblFuelCharge.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["adt_surcharge"].ToString();
                lblFreeBaggage.Text = dsFare.Tables[0].Rows[0]["free_baggage"].ToString();

                lblChdPrice.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["chd_price"].ToString();
                lblChdTax.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["chd_taxes"].ToString();
                lblChdFuel.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["chd_surcharge"].ToString();
                lblChdBaggage.Text = dsFare.Tables[0].Rows[0]["chd_baggage"].ToString();

                lblInfPrice.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["inf_price"].ToString();
                lblInfTax.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["inf_taxes"].ToString();
                lblInfFuel.Text = dsFare.Tables[0].Rows[0]["currency"] + dsFare.Tables[0].Rows[0]["inf_surcharge"].ToString();
                lblInfBaggage.Text = dsFare.Tables[0].Rows[0]["inf_baggage"].ToString();

                lblRules.Text = dsFare.Tables[0].Rows[0]["fare_rule"].ToString();
            }
            else
            {
                lblRules.Text = "Duplicated Fare or Fare Not Found! Call fare manager.";
            }
            //Response.End();

        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
            Response.End();
        }

    }
}
